<template>
	<view>
        <!-- 公共组件-每个页面必须引入 -->
        <public-module></public-module>
		<f-navbar title="分销中心" :bgColor="PrimaryColor" fontColor="#fff"></f-navbar>
		<view class="sellcenter" :style="'background:'+PrimaryColor">
			<view class="logbtn"><u-button type="primary" size="small" text="用户日志" @click="$tools.goJump('/pages/user/log',{},!userInfo.token,'')"></u-button></view>
                <u-row customStyle="width:100%;paddingTop:30px;color:#ffffff" justify="center" align="center">
                    <u-col span="6" align="center">
                        <view class="">资产总计</view>
						<view>{{paymentaccount.symbol}} {{paymentaccount.balance_total}}</view>
                    </u-col>
                    <u-col span="6" align="center">
                        <view class="">累计提现</view>
						<view>{{paymentaccount.symbol}} 0.00</view>
                    </u-col>
                </u-row>
			
			<view class="tixian">
				<u-button text="提现"
				 @click="$tools.goJump('/pagesPackageA/assets/ticash',{selectcoinid:1},!userInfo.token,'')"
				class="btn" :style="'background:'+PrimaryColor"></u-button>
			</view>
		</view>
		<view class="u-flex u-flex-middle">
                <view class="u-flex-6 itemBox u-flex-column u-flex-middle" @click="$tools.goJump('/pagesPackageA/sales/invite',{},!userInfo.token,'')">
					 <view><u--image src="/static/imgs/c1.png" width="40" height="40"></u--image></view>
					 <view>邀请链接</view>
				</view>
				
                <view v-if="userInfo.is_sunline==1" class="u-flex-6 itemBox u-flex-column u-flex-middle" @click="$tools.goJump('/pages/user/team_list',{},!userInfo.token,'')">
					<view><u--image src="/static/imgs/c3.png" width="40" height="40"></u--image></view>
					<view>我的团队</view>
				</view>
				
                <view v-if="userInfo.is_sunline==0" class="u-flex-6 itemBox u-flex-column u-flex-middle" @click="$tools.goJump('/pages/user/team_register',{},!userInfo.token,'')">
					<view><u--image src="/static/imgs/c3.png" width="40" height="40"></u--image></view>
					<view>我的团队</view>
				</view>

		</view>
		
<view class="u-padding-20">
    <view class="base-panel-box">
      <view class="htitle">
        <view>我的资产</view>
      </view>
      <view class="item" v-for="(item, index) in coin_list" :key="index" @click="$tools.goJump('/pagesPackageA/assets/flowdetail',{id: item.id, name: item.name},!userInfo.token,'')">
        <u-row gutter="0" justify="space-between">
          <u-col span="2">
            <image :src="item.icons"
              mode="aspectFill"
              style="width: 80rpx; height: 80rpx"/>
          </u-col>
          <u-col span="9">
            <view class="demo-layout bg-purple-light">
              <h4>{{ item.name }}</h4>
              <text>{{ item.balance_total }} {{ item.unit }}</text>
            </view>
          </u-col>
          <u-col span="1" textAlign="right">
            <u-icon name="arrow-right" color="#969799" size="14"></u-icon>
          </u-col>
        </u-row>
      </view>
    </view>
</view>

		
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import fNavbar from '@/components/module/f-navbar/f-navbar';
import { api_assets_paymentaccount,api_assets_list } from '@/config/api.js';

export default {
    components:{
        fNavbar
    },
	data() {
		return {
			paymentaccount:[],
			coin_list: {},
		};
	},
	computed:{
	    ...mapState(['PrimaryColor','userInfo']),
	},
	onLoad() {
		this.get_paymentaccount()
		this.getcoin();
	},
	methods: {
		get_paymentaccount() {
			api_assets_paymentaccount({}).then((res) => {
				this.paymentaccount=res
			}).catch((e) => {});
		},
		getcoin() {
		  return new Promise((resolve, reject) => {
		    this.loadstatus = true;
		    api_assets_list({}).then((res) => {
				console.log(res)
		        this.coin_list = res.list;
		        resolve(true);
		        this.loadstatus = false;
		      }).catch((e) => {
		        this.loadstatus = false;
		        resolve(false);
		      });
		  });
		},
	},
};
</script>

<style lang="scss" scoped>
page {
    background-color: #f5f5f5;
}
	.itemBox{
		padding: 24rpx;
		border-radius: 10rpx;
		background: #fff;
		text-align: center;
		margin: 10rpx;
	}
	.sellcenter{
		position: relative;
		margin-bottom: 35px;
		padding-bottom: 30px;
		height: 180px;
		background: #1C9C63;
		.logbtn{
			width: 100px;
			float: right;
			margin-right: 20px;
			margin-top: 10px;
		}
		.tixian {
			display: flex;
			justify-content: center;
			background-color: #F5F5F5;
			width: 55%;
			height: 60px;
			border-radius: 60px;
			position: absolute;
			bottom: -30px;
			left: 23%;

			.btn {
				margin-top: 7%;
				text-align: center;
				width: 85%;
				background-color: #1C9C63;
				height: 40px;
				border: none;
				border-radius: 50px;
				line-height: 40px;
				color: #FFFFFF;
			}
		}

		}
</style>
